]): Listen to windowDidResignMain notifications and properly update the
authorRichard Hult <richard@imendio.com>
Wed, 19 Jul 2006 17:06:40 +0000 (17:06 +0000)
committerRichard Hult <rhult@src.gnome.org>
Wed, 19 Jul 2006 17:06:40 +0000 (17:06 +0000)
2006-07-19  Richard Hult  <richard@imendio.com>

* gdk/quartz/GdkQuartzWindow.c
([GdkQuartzWindow -windowDidResignMain:]):
* gdk/quartz/gdkevents-quartz.c (_gdk_quartz_update_focus_window):
Listen to windowDidResignMain notifications and properly update the
focus window when windows are unfocused.

ChangeLog
ChangeLog.pre-2-10
gdk/quartz/GdkQuartzWindow.c
gdk/quartz/gdkevents-quartz.c
gdk/quartz/gdkprivate-quartz.h

index 4a7303bdddfd11207f938da7db8b9b0014494434..5fab3c2690282d165a43fb568db0367ebc2b6938 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-07-19  Richard Hult  <richard@imendio.com>
+
+       * gdk/quartz/GdkQuartzWindow.c
+       ([GdkQuartzWindow -windowDidResignMain:]):
+       * gdk/quartz/gdkevents-quartz.c (_gdk_quartz_update_focus_window):
+       Listen to windowDidResignMain notifications and properly update the
+       focus window when windows are unfocused.
+
 2006-07-19  Kristian Rietveld  <kris@imendio.com>
 
        * gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_init),
index 4a7303bdddfd11207f938da7db8b9b0014494434..5fab3c2690282d165a43fb568db0367ebc2b6938 100644 (file)
@@ -1,3 +1,11 @@
+2006-07-19  Richard Hult  <richard@imendio.com>
+
+       * gdk/quartz/GdkQuartzWindow.c
+       ([GdkQuartzWindow -windowDidResignMain:]):
+       * gdk/quartz/gdkevents-quartz.c (_gdk_quartz_update_focus_window):
+       Listen to windowDidResignMain notifications and properly update the
+       focus window when windows are unfocused.
+
 2006-07-19  Kristian Rietveld  <kris@imendio.com>
 
        * gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_init),
index 1c03de0bf832e36a1e3c866e108bd9c296d4917e..3fc35f83ea908d8a4b5097d2b6735ae4e4bd2f24 100644 (file)
 {
   GdkWindow *window = [[self contentView] gdkWindow];
 
-  _gdk_quartz_update_focus_window (window);
+  _gdk_quartz_update_focus_window (window, TRUE);
+}
+
+-(void)windowDidResignMain:(NSNotification *)aNotification
+{
+  GdkWindow *window = [[self contentView] gdkWindow];
+
+  _gdk_quartz_update_focus_window (window, FALSE);
 }
 
 -(void)windowDidMove:(NSNotification *)aNotification
index 409264a230eb2c9be1cedcd1c258200ca881e636..9129ae01ab8bf61b1bf2d5de703365123f725085 100644 (file)
@@ -748,24 +748,42 @@ create_focus_event (GdkWindow *window,
   return event;
 }
 
+/* Note: Used to both set a new focus window and to unset the old one. */
 void
-_gdk_quartz_update_focus_window (GdkWindow *new_window)
+_gdk_quartz_update_focus_window (GdkWindow *window,
+                                gboolean   got_focus)
 {
+  GdkEvent *event;
+
+  if (got_focus && window == current_keyboard_window)
+    return;
+
   /* FIXME: Don't do this when grabbed */
 
-  if (new_window != current_keyboard_window)
+  if (!got_focus)
     {
-      GdkEvent *event;
-
-      event = create_focus_event (current_keyboard_window, FALSE);
-      append_event (event);
+      if (window == current_keyboard_window)
+       {
+         event = create_focus_event (current_keyboard_window, FALSE);
+         append_event (event);
+         g_object_unref (current_keyboard_window);
+         current_keyboard_window = NULL;
+       }
+    }
 
-      event = create_focus_event (new_window, TRUE);
+  if (got_focus)
+    {
+      if (current_keyboard_window)
+       {
+         event = create_focus_event (current_keyboard_window, FALSE);
+         append_event (event);
+         g_object_unref (current_keyboard_window);
+         current_keyboard_window = NULL;
+       }
+      
+      event = create_focus_event (window, TRUE);
       append_event (event);
-
-      g_object_unref (current_keyboard_window);
-
-      current_keyboard_window = g_object_ref (new_window);
+      current_keyboard_window = g_object_ref (window);
     }
 }
 
@@ -1466,7 +1484,6 @@ gdk_event_translate (NSEvent *nsevent)
     case NSRightMouseUp:
     case NSOtherMouseUp:
       event = create_button_event (window, nsevent, x, y);
-
       append_event (event);
       
       /* Ungrab implicit grab */
@@ -1550,17 +1567,14 @@ gdk_event_translate (NSEvent *nsevent)
 void
 _gdk_events_queue (GdkDisplay *display)
 {  
-    if (current_event)
-      {
-       
-       if (!gdk_event_translate (current_event))
-         {
-           [NSApp sendEvent:current_event];
-         }
-       
-       [current_event release];
-       current_event = NULL;
-      }
+  if (current_event)
+    {
+      if (!gdk_event_translate (current_event))
+       [NSApp sendEvent:current_event];
+      
+      [current_event release];
+      current_event = NULL;
+    }
 }
 
 void
index 101fe80fedb0153ac003c1fb8285584ed406ec25..bbd1f72f8505b2913088e8f924065563f64c2230 100644 (file)
@@ -103,7 +103,8 @@ void _gdk_quartz_set_context_stroke_color_from_pixel (CGContextRef context, GdkC
 
 void _gdk_quartz_update_context_from_gc (CGContextRef context, GdkGC *gc);
 
-void _gdk_quartz_update_focus_window (GdkWindow *new_window);
+void _gdk_quartz_update_focus_window (GdkWindow *new_window,
+                                     gboolean   got_focus);
 
 gint _gdk_quartz_get_inverted_screen_y (gint y);